<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>
<html lang="en">
<head>
<style>
.control-group .controls label {
	display: inline-block;
}

</style>

</head>
<body class="wysihtml5-supported">
	<div id="content">
		<div class="container-fluid">
			<div class="row-fluid" id="rows">
				<div class="span12">
					<div class="widget-box">
						<div class="widget-title">
							<span class="icon"> <i class="icon-align-justify"></i>
							</span>
							<h5>UserInfo</h5>
						</div>
						<div class="widget-content nopadding">
							<form id="userForm" action="" method="post" class="form-horizontal">
								<div class="flexbox">
									<div class="flex-item">
										<label>userId :</label>										
										<input id="key" type="text" class="span4" name="userId" placeholder="用户ID">										
									</div>
									<div class="flex-item">										
										<label>userName :</label>										
										<input type="text" class="span4" name="userName" placeholder="用户名称">
									</div>
								</div>
								<div class="flexbox">
									<div class="flex-item">																
										<label>email :</label>										
										<input type="text" class="span6" name="email" placeholder="邮箱">										
									</div>
									<div class="flex-item">	
										<label>certNo :</label>
										<input type="text" class="span4" name="certNo" placeholder="身份证号码">
									</div>
								</div>
								<div class="flexbox">
									<div class="flex-item ">		
										<label>mobile :</label>
										<input type="text" class="span3" name="mobile" placeholder="电话号码">
									</div>
								</div>
								<div class="flexbox">
									<div class="flex-item">															
										<label>address :</label>										
										<input type="text" class="span8" name="email" placeholder="邮箱">										
									</div>
								</div>
								<div class="form-actions">
									<button type="button" class="btn btn-success" style="float:right" onclick="save()">保存</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script>
	    var _id = "";
		//初始化表单数据
		$(document).ready(function(){
			_id = "${param.id}";
			if(_id != null && _id != ""){
				$("#key").attr("readonly","readonly");
				$.ajax({
					url:"<%=path%>/user/get",
				    data:{"userId":_id},
				    type:"post",
				    success:function(text){
				    	if(text.success){
				    		$("#userForm").autofill(text.data);
				    	}
				    }
				});
			}
		});
		
		
		//保存表单数据
		function save(){
			var _editType = null ;
			if(_id != null && _id != ""){
				_eidtType = "edit";
				$("#userForm").prop("action","<%=path %>/user/update");
			}else{
				_editType = "add";
				$("#userForm").prop("action","<%=path %>/user/add");
			}
			//保存
			$("#userForm").ajaxSubmit(function(text){
				
				if(text.success){
					C.gritter("保存成功！");
					history.go(-1); //返回原页面
					//window.location.href="<%=path%>/user/list";
				}
			});
		}

	</script>
	
</body>
</html>

